package com.cong.websocketdemo.thread;

import javax.websocket.Session;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author cong
 * @since 2021/11/16 16:21
 */
public class TailfLogThread extends Thread{

    private BufferedReader reader;

    private Session session;

    TailfLogThread(InputStream in,Session session){
        this.reader=new BufferedReader(new InputStreamReader(in));
        this.session=session;
    }

    @Override
    public  void run(){
        String line;
        try {
            while ((line= reader.readLine())!=null){
                session.getBasicRemote().sendText(line+"<br>");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
